

		 **************************************************************
		 **															 **
		 ** Paper: Freedom of Foreign Movement and Human Trafficking **
		 **														     **
		 ** Authors: Sam R. Bell & Richard W. Frank 				 **
		 **															 **
		 ** Date: May 11, 2021										 **
		 **															 **
		 ** Task: Table 2-Extreme Bounds Analysis					 **
		 **															 **
		 **************************************************************
		  
									 
		clear
		version 16.1
		set seed 1234

		** change working directory
		cd "~"
		 
		use "ht_merged.dta"
		 
		merge 1:1 ccode year using "ht_eba_ivs.dta"
		drop _merge
		rename ccode cow
		merge 1:1 cow year using "CIRI 2011.dta"	
		rename cow ccode		 
		gen homi =ln(homicides)
	
		***********************************************************************
		* Model 2--HTI source, CIRI foreign movement, interaction term , 12km *
		***********************************************************************
		
			tsset ccode year
 	  
			probit F.source fm W_fm_con12  interact_W_C_f12 $IVs , robust cluster (ccode) 
			regsave using fom2_12km, replace
		
			tuples  			///
				KOFGI 			///
				lp_muslim80 	///
				rle 			///
				cpi 			///
				infant_mortality ///
				europe 			///
				mena 			///
				homi 			///
				food_bev 		///
				polity2			 ///
				overall3p 		///
				EU				///
				physint 		///
			, max(3) min(3)  kronecker
		
				forvalues i = 1/`ntuples'   {
				probit F.source fm W_fm_con12  interact_W_C_f12  `tuple`i'' gdp_ln pop_ln   , robust cluster (ccode) 
	
			regsave using fom2_12km, tstat pval ci autoid append detail(all) ///
					 			
						}
 
		***********************************************************************
		* Model 4--HTI source, VDEM foreign movement, interaction term , 12km *
		***********************************************************************

			tsset ccode year
 	  
			probit F.source v2clfmove W_vfomov_con12 interact_W_Vf12 , robust cluster(ccode)
			regsave using fom4_12km, replace
		
			tuples 				///
				KOFGI 			///
				lp_muslim80 	///
				rle 			///
				cpi 			///
				infant_mortality ///
				europe 			///
				mena 			///
				homi 			///
				food_bev 		///
				polity2			 ///
				overall3p 		///
				EU				///
				physint 		///
			, max(3) min(3)  kronecker
		
				forvalues i = 1/`ntuples'   {
				   probit F.source  v2clfmove W_vfomov_con12 interact_W_Vf12  `tuple`i'' gdp_ln pop_ln  , robust cluster(ccode)
	
			regsave using fom4_12km, tstat pval ci autoid append detail(all) ///
					 			
						}
		 	
				******************************
				*** CREATING RESULTS TABLE ***				
				******************************					
						
		use fom4_12km.dta, clear
		tab var
		
		gen x="F.source:physint"

		** dropping unnecessary variables **
			drop if _id==.
		** 1.1. regressions calculated
			codebook _id 
		** 1.3. Mean of Coef, SE, min, max    **
			sum coef if var==x
		
						***
		** 1.4.  %(significant != 0)  **
			count if var==x &   pval<=.05 & pval~=.
		** 1.5. %(beta < 0)   
			count if var==x & coef<0 & coef~=.
		** 1.5. %(beta > 0)  
			count if var==x & coef>0 & coef~=.		
		** 1.6.  %(signif & beta <= 0)  		
			count if var==x &  	pval<=.05 &	coef<=0 
		** 1.7.  %(signif & beta > 0)  		
			count if var==x &  	pval<=.05 &	coef>0 
			

		** 1.8 Sala-i-Martin's
		
		**Extreme Bounds Analysis (EBA):		 	  
 		cumul coef if var==x, gen(cdf) equal
		sort coef
		browse coef cdf  if cdf~=.	
				

		** CREATING COEFFICIENT GRAPH **
		
		import excel "fom1 results.xlsx", sheet("Sheet1") firstrow case(lower) clear

		drop if varname==""
		keep varname  order  lower_eb upper_eb mean 
	
		gen order2=.
		replace order2=1 if var== "GDP" 
 		replace order2=2 if var== "MENA"	
 		replace order2=3 if var== "Interaction term" 		
 		replace order2=4 if var== "Rule of Law" 
 		replace order2=5 if var== "Corruption"  
		replace order2=6 if var== "Infant mortality" 
 		replace order2=7 if var== "Muslim pop. (%)" 	
 		replace order2=8 if var== "Food/beverage" 		
 		replace order2=9 if var== "Polity2" 
 		replace order2=10 if var== "Globalization index"  		
		replace order2=11 if var== "Europe dummy" 
 		replace order2=12 if var== "Crime" 	
 		replace order2=13 if var== "Freedom of foreign mvm't" 		
 		replace order2=14 if var== "W" 
 		replace order2=15 if var== "Population"  		

	 	label define var2 	 			///
								1 "GDP"  ///
								2 "MENA"  ///
								3 "Interaction term" ///
								4 "Rule of Law" ///
								5 "Corruption" ///
								6 "Infant mortality" ///
								7 "Muslim pop. (%)" ///
								8 "Food/beverage" ///
								9 "Polity2" ///
								10 "Globalization index" ///
								11 "Europe dummy" ///
								12 "Crime" ///
								13 "Freedom of foreign mvm't" ///
								14 "W" ///
								15 "Population"
	 
				label value order2  var2

	 	    twoway (rspike lower_eb upper_eb order2 ,   horizontal	///
			msize(small) lwidth(vthin) lcolor(gs8)), ///
			xline(0, lcolor(cranberry) lwidth(vthin)) ///  
			xtitle("Coefficient", size(small)) ///
			ylabel(#23,   valuelabel angle(zero) tlc(none) labsize(small)) ///
			ytitle("") ///
			graphregion(margin(l=40)) ///
			name(coef, replace) || ///
			scatter order2 mean  ,   msize(tiny)  msymbol(sh) mcolor(gs2) legend(off)	
			graph save fom_sign.gph, replace

		
		********* HISTOGRAMS **

	global graph_options ",  freq	xline(0, lcolor(red)) ytitle("") xtitle("") normal gap(25) ylabel(, angle(0) labsize(small))"
	
		global tgraph_options ",  freq	xline(1.98 -1.98, lcolor(red)) ytitle("") xtitle("")  gap(25) ylabel(, angle(0) labsize(small))"

	* 1 *
	use fom1.dta, clear
	hist coef if var=="F.source:W_vfomov_con24"  $graph_options title("W") 
	graph save h1.gph, replace
	hist tstat if var=="F.source:W_vfomov_con24"  $tgraph_options title("W") 	
	graph save h1t.gph, replace

	* 2 *
	use fom1.dta, clear
	hist coef if var=="F.source:v2clfmove"  $graph_options title("Freedom of Movement") 
	graph save h2.gph, replace
	hist tstat if var=="F.source:v2clfmove"  $tgraph_options title("Freedom of Movement") 	
	graph save h2t.gph, replace

	* 3 *
	use fom1.dta, clear
	hist coef if var=="F.source:interact_W_Vf24"  $graph_options title("Interaction term") 
	graph save h3.gph, replace
	hist tstat if var=="F.source:interact_W_Vf24"  $tgraph_options title("Interaction term") 	
	graph save h3t.gph, replace		
	
	* 4 *
	use fom1.dta, clear
	 
	hist coef if var=="F.source:cpi"  $graph_options title("Corruption") 
	graph save h4.gph, replace
	hist tstat if var=="F.source:cpi"  $tgraph_options title("Corruption") 	
	graph save h4t.gph, replace	
	
	* 5 *
	use fom1.dta, clear
	hist coef if var=="F.source:homi"  $graph_options title("Crime") 
	graph save h5.gph, replace
	hist tstat if var=="F.source:homi"  $tgraph_options title("Crime") 	
	graph save h5t.gph, replace
	
	* 6 *
	use fom1.dta, clear
	hist coef if var=="F.source:europe"  $graph_options title("Europe") 
	graph save h6.gph, replace
	hist tstat if var=="F.source:europe"  $tgraph_options title("Europe") 	
	graph save h6t.gph, replace	
	
	* 7 *
	use fom1.dta, clear
	hist coef if var=="F.source:food_bev"  $graph_options title("Food/Beverage") 
	graph save h7.gph, replace
	hist tstat if var=="F.source:food_bev"  $tgraph_options title("Food/Beverage") 	
	graph save h7t.gph, replace	
	
	* 8 *
	use fom1.dta, clear
	hist coef if var=="F.source:gdp_ln"  $graph_options title("GDP") 
	graph save h8.gph, replace
	hist tstat if var=="F.source:gdp_ln"  $tgraph_options title("GDP") 	
	graph save h8t.gph, replace	
	
	* 9 *
	use fom1.dta, clear
	hist coef if var=="F.source:KOFGI"  $graph_options title("Globalization") 
	graph save h9.gph, replace
	hist tstat if var=="F.source:KOFGI"  $tgraph_options title("Globalization") 	
	graph save h9t.gph, replace	
	
	* 10 *
	use fom1.dta, clear
	hist coef if var=="F.source:infant_mortality"  $graph_options title("Infant mortality") 
	graph save h10.gph, replace
	hist tstat if var=="F.source:infant_mortality"  $tgraph_options title("Infant mortality") 	
	graph save h10t.gph, replace	
	
	* 11 *
	use fom1.dta, clear
	hist coef if var=="F.source:mena"  $graph_options title("MENA") 
	graph save h11.gph, replace
	hist tstat if var=="F.source:mena"  $tgraph_options title("MENA") 	
	graph save h11t.gph, replace	
	
	* 12 *
	use fom1.dta, clear
	hist coef if var=="F.source:lp_muslim80"  $graph_options title("Muslim %") 
	graph save h12.gph, replace
	hist tstat if var=="F.source:lp_muslim80"  $tgraph_options title("Muslim %") 	
	graph save h12t.gph, replace	
	
	* 13 *
	use fom1.dta, clear
	hist coef if var=="F.source:polity2"  $graph_options title("Polity2") 
	graph save h13.gph, replace
	hist tstat if var=="F.source:polity2"  $tgraph_options title("Polity2") 	
	graph save h13t.gph, replace	
	
	* 14 *
	use fom1.dta, clear
	hist coef if var=="F.source:pop_ln"  $graph_options title("Population") 
	graph save h14.gph, replace
	hist tstat if var=="F.source:pop_ln"  $tgraph_options title("Population") 	
	graph save h14t.gph, replace	
	
	* 15 *
	use fom1.dta, clear
	hist coef if var=="F.source:rle"  $graph_options title("Rule of law") 
	graph save h15.gph, replace
	hist tstat if var=="F.source:rle"  $tgraph_options title("Rule of law") 	
	graph save h15t.gph, replace	
 
	
	graph combine 	h2.gph h1.gph h3.gph h4.gph h5.gph 		///
					h6.gph h7.gph h8.gph h9.gph h10.gph 	///
					h11.gph h12.gph h13.gph h14.gph h15.gph   
		 
	graph combine 	h2t.gph h1t.gph h3t.gph h4t.gph h5t.gph 		///
					h6t.gph h7t.gph h8t.gph h9t.gph h10t.gph 	///
					h11t.gph h12t.gph h13t.gph h14t.gph h15t.gph   	
		
		
